import { SelectProps, Select } from 'antd'
import { useState } from 'react'
export default function SelectTrim(props: SelectProps) {
  // 去除空格
  const [searchValue, setsearchValue] = useState('')
  return (
    <Select
      {...props}
      showSearch={!!props.onSearch}
      searchValue={searchValue}
      onSearch={
        props.onSearch
          ? (str, ...set) => {
              props.onSearch!(str.trim(), ...set)
              setsearchValue(str.trim())
            }
          : undefined
      }
      onSelect={(...set) => {
        props.onSelect && props.onSelect(...set)
        setsearchValue('')
      }}
    ></Select>
  )
}
